<?php
/* SVN FILE: $Id: view.ctp 34 2009-10-17 13:42:12Z kenreily@gmail.com $ */
/**
 * Short description for file.
 *
 * Long description for file
 *
 * PHP versions 4 and 5
 *
 * Recenseo: Online submission and reviewing for education
 * Copyright 2008-2009, Ken Reily
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * $Date: 2009-10-17 13:42:12 +0000 (Sat, 17 Oct 2009) $
 * $Revision: 34 $
 * $Author: kenreily@gmail.com $
 * $HeadURL: http://recenseo.googlecode.com/svn/trunk/app/views/assessments/view.ctp $
 */

  if (!empty($assessment))
  {
    $user = $session->read('Auth.User');

    // Don't show the download link for the user whose submission this is.
    // They can download it from their submission screen.
    if ($assessment['Submission']['user_id'] != $user['id'])
    { 
?>
<p>
<dl>
  <dt>File</dt>
  <dd><?= $html->link($submission['Submission']['file_name'],'/submissions/download/' . $assessment['Submission']['id']) ?> (Click to download)</dd>
  
  <dt>Type</dt>
  <dd><?= $submission['Submission']['file_type'] ?></dd>
  
  <dt>Size</dt>
  <dd><?= number_format($submission['Submission']['file_size'] / 1024,1) . 'kb' ?></dd>
  
  <dt>Grading Option</dt>
  <dd><?= $submission['GradingOption']['name'] ?></dd>

<?php
    if (!empty($submission['Submission']['comments'])) 
    {
?>  
  <dt>Comments</dt>
  <dd><?= $submission['Submission']['comments'] ?>&nbsp;</dd>
<?php
    }
?>
</dl>
</p>
<?php
    }
?>
<h4>Test Cases</h4>
<table width="100%">
<?php
  echo $html->tableHeaders(array('#','Name','Description','Results','Outcome'));
    
  if (count($test_cases) > 0)
  {
    foreach ($test_cases as $test_case)
    {
      echo $html->tableCells(array($test_case['TestCase']['id'],
                                   $test_case['TestCase']['name'],
                                   $test_case['TestCase']['description'],
                                   $test_case['AssessmentTestCase']['results'],
                                   $test_case['TestCaseResult']['name']),
                             array('class' => 'altrow'));
    }        
  }
  else
  {
?>
<tr><td colspan="6">No Test Cases Found.</td></tr>
<?php
  }
?>
</table>
<p><?=count($test_cases) ?> Completed Test Cases
<br>
<h4>Submission Qualities</h4>
<table>
<?php
    echo $html->tableHeaders(array('Quality','Response','Comments'));
    
    foreach ($qualities as $quality)
    {
      if (empty($quality['LikertResult']['name']))
      {
        $response = '(None)';
      }
      else
      {
        $response = $quality['LikertResult']['name'];
      }
      
      $comments = $quality['AssessmentQualityAttribute']['comments'];
      
      if (empty($comments))
      {
        $comments = '(None)';
      }
             
      echo $html->tableCells(array($quality['QualityAttribute']['name'],$response,$comments),null,array('class' => 'altrow'));       
    }
?>
</table>
<p>Submitted: <?=$time->nice($assessment['Assessment']['submitted']) ?>.</p>
<?php
    if (!empty($assessment['Assessment']['author_rating']) ||
        !empty($ratings))
    {
?>
<h4>Ratings</h4>
<table>
<?php
      echo $html->tableHeaders(array('Rated By','Rating (out of 5)','Comments'));

      $comments = $assessment['Assessment']['author_comments'];

      if (empty($comments))
      {
        $comments = '-';
      }

      echo $html->tableCells(array('Author', 
                                   $assessment['Assessment']['author_rating'],
                                   $comments));

      if ($assessment['Assessment']['user_id'] == $user['id'] || $user['role'] == 'Instructor')
      {
        foreach ($ratings as $rating)
        {
	  $comments = $rating['AssessmentRating']['comments'];
        
          if (empty($comments))
          {
            $comments = '-';
          }

          echo $html->tableCells(array('Peer',
                                       $rating['AssessmentRating']['rating'],
                                       $comments));
        }
      } 
?>
</table>
<?php 
    }
  }
?>